package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.QMenu3;
import com.ruoyi.system.service.IQMenu3Service;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 三级目录Controller
 * 
 * @author ruoyi
 * @date 2024-06-19
 */
@Controller
@RequestMapping("/system/menu3")
public class QMenu3Controller extends BaseController
{
    private String prefix = "system/menu3";

    @Autowired
    private IQMenu3Service qMenu3Service;

    @RequiresPermissions("system:menu3:view")
    @GetMapping()
    public String menu3()
    {
        return prefix + "/menu3";
    }

    /**
     * 查询三级目录列表
     */
    @RequiresPermissions("system:menu3:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(QMenu3 qMenu3)
    {
        startPage();
        List<QMenu3> list = qMenu3Service.selectQMenu3List(qMenu3);
        return getDataTable(list);
    }

    /**
     * 导出三级目录列表
     */
    @RequiresPermissions("system:menu3:export")
    @Log(title = "三级目录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(QMenu3 qMenu3)
    {
        List<QMenu3> list = qMenu3Service.selectQMenu3List(qMenu3);
        ExcelUtil<QMenu3> util = new ExcelUtil<QMenu3>(QMenu3.class);
        return util.exportExcel(list, "三级目录数据");
    }

    /**
     * 新增三级目录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存三级目录
     */
    @RequiresPermissions("system:menu3:add")
    @Log(title = "三级目录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(QMenu3 qMenu3)
    {
        return toAjax(qMenu3Service.insertQMenu3(qMenu3));
    }

    /**
     * 修改三级目录
     */
    @RequiresPermissions("system:menu3:edit")
    @GetMapping("/edit/{q3Id}")
    public String edit(@PathVariable("q3Id") Long q3Id, ModelMap mmap)
    {
        QMenu3 qMenu3 = qMenu3Service.selectQMenu3ByQ3Id(q3Id);
        mmap.put("qMenu3", qMenu3);
        return prefix + "/edit";
    }

    /**
     * 修改保存三级目录
     */
    @RequiresPermissions("system:menu3:edit")
    @Log(title = "三级目录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(QMenu3 qMenu3)
    {
        return toAjax(qMenu3Service.updateQMenu3(qMenu3));
    }

    /**
     * 删除三级目录
     */
    @RequiresPermissions("system:menu3:remove")
    @Log(title = "三级目录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(qMenu3Service.deleteQMenu3ByQ3Ids(ids));
    }
}
